package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DownloadHistoryMapper;
import com.ruoyi.system.domain.DownloadHistory;
import com.ruoyi.system.service.IDownloadHistoryService;
import com.ruoyi.common.core.text.Convert;

/**
 * 下载记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-12
 */
@Service
public class DownloadHistoryServiceImpl implements IDownloadHistoryService 
{
    @Autowired
    private DownloadHistoryMapper downloadHistoryMapper;

    /**
     * 查询下载记录
     * 
     * @param historyId 下载记录主键
     * @return 下载记录
     */
    @Override
    public DownloadHistory selectDownloadHistoryByHistoryId(Long historyId)
    {
        return downloadHistoryMapper.selectDownloadHistoryByHistoryId(historyId);
    }

    /**
     * 查询下载记录列表
     * 
     * @param downloadHistory 下载记录
     * @return 下载记录
     */
    @Override
    public List<DownloadHistory> selectDownloadHistoryList(DownloadHistory downloadHistory)
    {
        return downloadHistoryMapper.selectDownloadHistoryList(downloadHistory);
    }

    /**
     * 新增下载记录
     * 
     * @param downloadHistory 下载记录
     * @return 结果
     */
    @Override
    public int insertDownloadHistory(DownloadHistory downloadHistory)
    {
        downloadHistory.setCreateTime(DateUtils.getNowDate());
        return downloadHistoryMapper.insertDownloadHistory(downloadHistory);
    }

    /**
     * 修改下载记录
     * 
     * @param downloadHistory 下载记录
     * @return 结果
     */
    @Override
    public int updateDownloadHistory(DownloadHistory downloadHistory)
    {
        downloadHistory.setUpdateTime(DateUtils.getNowDate());
        return downloadHistoryMapper.updateDownloadHistory(downloadHistory);
    }

    /**
     * 批量删除下载记录
     * 
     * @param historyIds 需要删除的下载记录主键
     * @return 结果
     */
    @Override
    public int deleteDownloadHistoryByHistoryIds(String historyIds)
    {
        return downloadHistoryMapper.deleteDownloadHistoryByHistoryIds(Convert.toStrArray(historyIds));
    }

    /**
     * 删除下载记录信息
     * 
     * @param historyId 下载记录主键
     * @return 结果
     */
    @Override
    public int deleteDownloadHistoryByHistoryId(Long historyId)
    {
        return downloadHistoryMapper.deleteDownloadHistoryByHistoryId(historyId);
    }
}
